import urllib.request
import urllib.parse
import json
url = 'https://fanyi.baidu.com/v2transapi?from=en&to=zh'
data = {
    'from': 'en',
    'to': 'zh',
    'query': 'love',
    'transtype': 'realtime',
    'simple_means_flag': '3',
    'sign': '198772.518981',
    'token': 'e01fc21536cec6cf70d3c6b68508978e',
    'domain': 'common',
    'ts': '1713088687925'
}
headers= {
'Cookie': 'BIDUPSID=B4B53B8FBA29466BDB5424ADE7C08FD7; PSTM=1641197634; REALTIME_TRANS_SWITCH=1; FANYI_WORD_SWITCH=1; SOUND_SPD_SWITCH=1; HISTORY_SWITCH=1; SOUND_PREFER_SWITCH=1; BAIDU_WISE_UID=wapp_1643683143242_941; BAIDUID_BFESS=827906BDF743BFAA561C07E07C33841A:FG=1; __bid_n=186d03c912b6be3e4d4207; FPTOKEN=vWkrmcsOxMydqnp2Qs9KRZuZqU+FhfB1W39qkzuextHiaLzClgjoKfkhtofF+ab8rGS7mHpMjUJEHweYoxkewRL/h4FAjz5rxD8ssDBgxEctnSE1d14bQSUCfEkrLkk7jdEnlcYBq0jPvMXGbqds7A2f2GR+RY/UZngb1yBqM03sqF5FXNkGyet0zj3h3REmuABtwI9WEomCbcj0ejpWtdh7K+IjqI8TrnLIpE3I+NweGzsXOnNSkIzlkh1o0dZeivzEPEbvkI5Pi2gyjuIFbIfG7z7eTPjAXkNkA00Cgzni8nwesHtH+luHCqW9MFcnzPBP2CPHG6vQl2jlE+wICqNVqnPNNisSn5+ScDWJHawasKc3pIkaY37qjJW0gz5/AsRQKRHK/mrmpAsQ1rwB0w==|v9CKClDcicvPnWI+4F6UINnV2HhSjnkw2dG38gpzWwU=|10|6e2e1d5177a72bda6484f9443b064991; MCITY=-340%3A; ZFY=Vc4t3gD7Z5l8o9odfJZuMKRUv:A32Eo8FvjMphfQO7LU:C; H_PS_PSSID=40368_40378_40303_40480_39662_40511_40514_40398_60045_60026_60048_60059; BA_HECTOR=0k0405ak24ak80ak01852h21kppmu41j1mn3f1t; BDORZ=B490B5EBF6F3CD402E515D22BCDA1598; PSINO=7; delPer=0; BDRCVFR[dG2JNJb_ajR]=mk3SLVN4HKm; BDRCVFR[-pGxjrCMryR]=mk3SLVN4HKm; smallFlowVersion=old; RT="z=1&dm=baidu.com&si=87509667-f49a-4fd4-bb20-d77103cf838c&ss=luzax3zt&sl=b&tt=44u&bcn=https%3A%2F%2Ffclog.baidu.com%2Flog%2Fweirwood%3Ftype%3Dperf&ld=sd8d&ul=1olen&hd=1olly"; Hm_lvt_64ecd82404c51e03dc91cb9e8c025574=1713088401; Hm_lpvt_64ecd82404c51e03dc91cb9e8c025574=1713088401; APPGUIDE_10_7_2=1; ab_sr=1.0.1_YTgzMWRkMmZlZWNkMmMyNjczMTE2MjRjNTgxNzcwZGYxMmFmZWIxMGY4MzNjN2FhZDk4NTJjZjRmNmU3NGE3M2VlZTE3MGYzYmQ4NzkyZWM3YWNhZTQxODhmZGM2N2MyMDExMDRhYmRiMjUzNWIzNmEzNjQ1MDU1YzU0NmUxYzJkNGZkYjIzZmFmYzJmYmYwYTI0OTRiYzYyNGYxZDBjMGJhNzI3YWFjODgwNjI2ZmQ1ZGRmYWU4MTQ5YjQ0ODQxNzczZDlhOWQwZmUxMzdmNjgxZDRjYTcwMTM1Y2FmNzc='

}
key_data = urllib.parse.urlencode(data).encode('utf-8')
request = urllib.request.Request(url=url,data=key_data,headers=headers)
response = urllib.request.urlopen(request)
content = response.read().decode('utf-8')
print(json.loads(content))